package com.cyb.myfriend.service;


import com.baomidou.mybatisplus.extension.service.IService;
import com.cyb.myfriend.domain.entity.Team;
import com.cyb.myfriend.domain.entity.User;
import com.cyb.myfriend.domain.request.TeamJoinRequest;
import com.cyb.myfriend.domain.request.TeamQuitRequest;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
* @author 78570
* @description 针对表【team(队伍)】的数据库操作Service
* @createDate 2024-08-27 17:11:42
*/
public interface TeamService extends IService<Team> {

    /**
     * 创建队伍
     *
     * @param team 队伍信息
     * @return 队伍Id
     */
    int saveTeam(Team team);

    /**
     * 更新队伍表
     *
     * @param userId userId
     * @param team 需要修改的队伍信息
     * @return Integer
     */
    Integer updateTeam(Long userId, Team team);

    /**
     * 根据队伍名称搜索队伍（模糊查询）
     *
     * @param teamName 队伍名称
     * @return List<Team>
     */
    List<Team> searchTeamByTeamName(String teamName);

    boolean joinTeam(TeamJoinRequest teamJoinRequest, User loginUser);

    @Transactional(rollbackFor = Exception.class)
    boolean quitTeam(TeamQuitRequest teamQuitRequest, User loginUser);

    /**
     * 删除队伍
     *
     * @param id
     * @param loginUser
     * @return
     */
    boolean deleteTeam(long id, User loginUser);

}
